package com.ssy.lingxi.common.constant.basic;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 *  客户端类型
 * @author ds
 * @date 2021/9/7
 * @version 2.0.0
 */
public enum ClientTypeEnum {

    /**
     * PC
     */
    PC(1, "PC"),

    /**
     * APP
     */
    APP(2, "APP");

    /**
     * 枚举值
     */
    private Integer code;

    /**
     * 描述
     */
    private String name;

    ClientTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static List<Integer> toList() {
        return Arrays.stream(ClientTypeEnum.values()).map(ClientTypeEnum::getCode).collect(Collectors.toList());
    }

    public static String getNameByCode(Integer code) {
        ClientTypeEnum status = Arrays.stream(ClientTypeEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(null);
        return status == null ? "未知" : status.getName();
    }
}
